`timescale 1ns / 1ps

module rnd_generator_register(
	input [31:0] rnd_seed,

	output [14:0] rnd_num0,
	output [14:0] rnd_num1,
	output [14:0] rnd_num2,
	output [14:0] rnd_num3,
	output [14:0] rnd_num4
	);
	
	reg [31:0] recv_seed;
	reg [44:0] rnd_num;

	// Choosing of the numbers is quite *random*
	// Hope it can brings a little randomness
	assign rnd_num0 = rnd_num[44:30];
	assign rnd_num1 = rnd_num[39:25];
	assign rnd_num2 = rnd_num[29:15];
	assign rnd_num3 = rnd_num[24:9];
	assign rnd_num4 = rnd_num[19:4];
	
	always @(rnd_seed) begin
		// If you accidentally get a even number, you may get many zeros in lower bits after cubing
		// The if-else statements is aimed for solving this problem - change even into odd by simply adding 'b1
		// How robust!
		if (rnd_seed[0]) begin
			recv_seed = rnd_seed;
		end else begin
			recv_seed = rnd_seed + 'b1;
		end
		
		// right, this is our random number generating algorithm: TO CUBE IT!!!!!
		rnd_num <= recv_seed*recv_seed*recv_seed;
	end
endmodule
